<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="uct" uri="/WEB-INF/uct.tld" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/sale/include/common-base.jsp"%>
  <script type="text/javascript" src="${ctx}/js/tools-upload.js"></script>
  <title>${param.proNo}-配号结果管理-${titleName}</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor}  sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/sale/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/sale/left.jsp" %>
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <!------搜索  start ------->
          <div class="box box-info">
             <!--搜索title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-search"></i> 查询搜索</h3>
                 <div class="box-tools pull-right" style="display: none;">
	                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>
            <!--搜索title  end --> 
            <div class="box-body">
			  <form id="searchForm" class="form-horizontal">
				<input type="hidden" name="doCode" value="dymicSql"/>
				<input type="hidden" name="pageName" value="trsNumbers-list">
				<input type="hidden" name="formName" value="searchForm">
				<input type="hidden" name="trsNumbers.w_delStatus" value="F">
				<input type="hidden" name="trsNumbers.w_saleId" value="${param.saleId }">
			    <input type="hidden" name="orderBy" value="trsNumbers.rand_number">
				
				<div class="col-sm-11">
				   <div class="form-group">	  
					   <div class="col-sm-2 text_r"><label class="control-label" >商品名称：</label></div>
						<div class="col-sm-2">
						 <input type="text" class="form-control clean"  name="trsNumbers.wl_proName" value="" id="wl_proName"/>
						</div>
					   <div class="col-sm-2 text_r"><label class="control-label" >交易商账号：</label></div>
						<div class="col-sm-2">
						 <input type="text" class="form-control clean"  name="trsNumbers.wl_userOwner" value="" id="wl_userOwner"/>
						</div>
					   <div class="col-sm-2 text_r"><label class="control-label" >是否中签：</label></div>
						<div class="col-sm-2">
						 <select id="searchForm_isSelect" name="trsNumbers.wl_isSelect" class="form-control clean" 
						  data-url="doCode=dictItemList&cateEname=yesOrNo" data-colmun="" data-type="select">
						  </select>
						</div>
					</div>
					<center>
					   <div class="box-footer clearfix">
					       <button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-edit-circle"></i> 查询</button> 
					       <button  type="button" class="btn btn-warning" onclick="cleanData('searchForm');">重置 </button>
					   </div>
					</center>
				</div>
			  </form>
            </div>
	     </div>
	     <!------- 搜索 end -------->
           
        <!------- 列表 start -------->
          <div class="box box-success">
            <!--列表title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-user"></i> [${param.proNo}-${param.proName}] 配号结果列表 </h3>
                 <button type="button" class="btn btn-success" onclick="window.history.back();"><i class="fa fa-arrow-circle-left"></i> 返回</button> 
                 <div class="box-tools pull-right" style="display: none;">
	                 　　　　　　　　<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>
            <!--列表title  end --> 
              <div class="box-body">
                <table id="dataList" class="table table-bordered table-hover" >
                <thead class="bg-success">
                <tr>
                        <th class="text_c">序号</th>
                        <th class="text_c">商品代码</th>
                        <th class="text_c">商品名称</th>
                        <th class="text_c">交易商账号</th>
                        <th class="text_c">配号号码</th>
                        <th class="text_c">配号时间</th>
                        <th class="text_c">配号数量</th>
                        <th class="text_c">发行单价（元）</th>
                        <th class="text_c">是否中签</th>
                        <th class="text_c">是否付款</th>
    					<th class="text_c">说明</th>
                </tr>
                </thead>
                <tbody id="dataList-body">
                </tbody>
              </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
           </div>
        <!------- 列表 end -------->
        </div>
      </div>
    </section>
    <!-- Main end -->
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/sale/foot.jsp" %>
  <!-- foot start -->
  

<div class="modal fade" id="my_modal_add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">信息添加</font> 
						</h4>
					</div>

					<div class="modal-body">
						<form class="form-horizontal" role="form" id="addForm">
							<input type="hidden" id="addForm_formToken" name="formToken" >
							<input type="hidden" name="doCode" value="dymicSql"/>
							<input type="hidden" name="pageName"  value="trsNumbers-list">
							<input type="hidden" name="formName"  value="addForm">
							<input type="hidden" name="trsNumbers.delStatus" value="F">
						
							
					        <div class="box-body" id="addForm_submitFormData">
					          <!-- Custom Tabs -->
					          <div class="nav-tabs-custom">
					            <div class="tab-content">
					              <div class="tab-pane active" id="tab_1">
					              
									<div class="form-group">
						                  <label class="col-sm-3 control-label" >配号号码</label>
						                  <div class="col-sm-8">
						                	<input type="text" id="addForm_randNumber" name="trsNumbers.randNumber" class="form-control clean" maxLength="50" required placeholder="必填项" />
						                  </div>
							        </div>

									<div class="form-group">
						                  <label class="col-sm-3 control-label" >是否中签</label>
						                  <div class="col-sm-8">
						                		<select id="addForm_isSelect" name="trsNumbers.isSelect" class="form-control" 
						                		data-url="doCode=dictItemList&cateEname=yesOrNo" data-colmun="" data-type="select">
						                		</select>
						                  </div>
							        </div>

									<div class="form-group">
						                  <label class="col-sm-3 control-label" >交易商账号</label>
						                  <div class="col-sm-8">
						                	<input type="text" id="addForm_userOwner" name="trsNumbers.userOwner" class="form-control clean" maxLength="50" required placeholder="必填项" />
						                  </div>
							        </div>

					              </div>					             
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          </div>
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-left" onclick="cannel('add');">取消</button>
				                <button type="button" class="btn btn-danger pull-right" onclick="add('addForm');">提 交</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  

<div class="modal fade" id="my_modal_edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">信息修改</font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="editForm">
							<input type="hidden" id="editForm_formToken" name="formToken" >
							<input type="hidden" name="doCode" value="dymicSql"/>
							<input type="hidden" name="pageName"  value="trsNumbers-list">
							<input type="hidden" name="formName"  value="editForm">
							<input type="hidden" id="w_numberId" data-name="trsNumbers.numberId" name="trsNumbers.w_numberId"  value="">
							
							
					        <div class="box-body" id="editForm_submitFormData">
					          <!-- Custom Tabs -->
					          <div class="nav-tabs-custom">
					            <div class="tab-content">
					              <div class="tab-pane active" id="tab_1">
					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >配号号码</label>
					                  <div class="col-sm-8">
									  <input type="text" id="editForm_randNumber" data-name="trsNumbers.randNumber" name="trsNumbers.randNumber" class="form-control clean" maxLength="50" required placeholder="必填项" />
					                  </div>
					                </div>

					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >是否中签</label>
					                  <div class="col-sm-8">
									  <select id="editForm_isSelect" data-name="trsNumbers.isSelect" name="trsNumbers.isSelect" class="form-control" 
									  data-url="doCode=dictItemList&cateEname=yesOrNo" data-colmun="" data-type="select">
									  </select>
					                  </div>
					                </div>

					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >交易商账号</label>
					                  <div class="col-sm-8">
									  <input type="text" id="editForm_userOwner" data-name="trsNumbers.userOwner" name="trsNumbers.userOwner" class="form-control clean" maxLength="50" required placeholder="必填项" />
					                  </div>
					                </div>

					              </div>					             
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          </div>
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-left" onclick="cannel('edit');">取消</button>
				                <button type="button" class="btn btn-danger pull-right" onclick="edit('editForm');">提 交</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  

<div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">查看详情</font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="viewForm">
					        <div class="box-body">
					          <!-- Custom Tabs -->
					          <div class="nav-tabs-custom">
					            <div class="tab-content">
					              <div class="tab-pane active" id="tab_1">
					              
					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >配号号码</label>
					                  <div class="col-sm-8">
										<span data-name="trsNumbers.randNumber"></span>
					                  </div>
					                </div>

					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >是否中签</label>
					                  <div class="col-sm-8">
										<span data-name="trsNumbers.isSelect" data-dict-url="doCode=dictItemList&cateEname=yesOrNo"></span>
					                  </div>
					                </div>

					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >交易商账号</label>
					                  <div class="col-sm-8">
										<span data-name="trsNumbers.userOwner"></span>
					                  </div>
					                </div>

					              </div>					             
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          </div>
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-right" onclick="cannel('view');">关闭</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>
</body>


<!-- 以下是template列表模板的模块区域 -->
<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
			<td class="text_c"><?=(pageObj.currentPage-1)*10+(i+1) ?></td>		
			<td class="text_c"><?=strUtil.doNull(rows[i].proNo,'')?></td>		
			<td class="text_c"><?=strUtil.doNull(rows[i].proName,'')?></td>		
			<td class="text_c"><?=strUtil.doNull(rows[i].userOwner,'')?></td>		
			<td class="text_c"><?=strUtil.doNull(rows[i].randNumber,'')?></td>
			<td class="text_c"><?=strUtil.doNull(rows[i].createTime,'')?></td>	
			<td class="text_r"><?=strUtil.doNull(rows[i].nums,'')?></td>	
			<td class="text_r">￥<?=fmoney(rows[i].price,'')?></td>	
			<td class="text_c"><?=yesOrNo(rows[i].isSelect)?></td>
			<td class="text_c"><?=yesOrNo(rows[i].isPay)?></td>
			<td class="text_l"><?=strUtil.doNull(rows[i].remark,'')?></td>
             
		</tr>
   <?}?>  		
</script>

</html>

<!-- 以下是js模块区域 -->
<script>
var clickMenu = "bjtesale-sale-list";
//var clickMenu = "trsNumbers-list";
var id,myPage,dataListId,searchFormId,isShowLog,tableSort,tableId;
myPage = 10;
dataListId = "dataList";
searchFormId = "searchForm";
tableSort = "trsNumbers";
tableId = "numberId";
isShowLog = true;

$(function () {
	//1、加载分页列表数据
	DictUtil.getCommonDictData("select","#searchForm_isSelect","trsNumbers.isSelect","doCode=dictItemList&cateEname=yesOrNo","","");
	getTableData();
	//2、控制是否启用token
	//setToken();
	
	//请在下面补充其他初始化方法（如数据字典、页面加载数据等）
	//3、初始化数据字典
	//DictUtil.getCommonDictData("select","#addForm_isSelect","trsNumbers.isSelect","doCode=dictItemList&cateEname=yesOrNo","","");
	//DictUtil.getCommonDictData("select","#addForm_isPay","trsNumbers.isPay","doCode=dictItemList&cateEname=yesOrNo","","");
 });
var dateObject = $('.datepicker').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true
});
//读取（查询、编辑）数据
function toLoad(id,type){
	var paramLoadData = {"trsNumbers.w_numberId":id,"modelTypes":"s_"+tableSort};
	loadObj(type,paramLoadData);
}
function toDele(id){
	var index_submit = layer.confirm('您确定要删除信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var paramLoadData = {"modelTypes":"d_trsNumbers","trsNumbers.w_numberId":id};
		//var paramLoadData = {"modelTypes":"u_trsNumbers","trsNumbers.delStatus":"T","trsNumbers.w_numberId":id};
		doDele(paramLoadData);
	});
}
//反显数据
function showData(type,myData){
	console.log(myData);
	if("view"==type){
		FormUtil.loadView("trsNumbers", myData);
		$("#my_modal_view").modal("show");
	}else if("edit"==type){
		//修改弹框时，初始化数据字典
		cleanData('editForm_submitFormData');
		DictUtil.getCommonDictData("select","#editForm_isSelect","trsNumbers.isSelect","doCode=dictItemList&cateEname=yesOrNo","",myData.isSelect);
		DictUtil.getCommonDictData("select","#editForm_isPay","trsNumbers.isPay","doCode=dictItemList&cateEname=yesOrNo","",myData.isPay);
		FormUtil.loadView("trsNumbers", myData);
		//FormUtil.fillData("#editForm", myData,"id");
		$("#w_"+tableId).val(myData.numberId);
		$("#my_modal_edit").modal("show");
	}
}



$(function () {
	$('#'+dataListId+' tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	            //$(this).removeClass('selected');
	        }
	        else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     id = $('tr.selected td').eq(0).html();
	   //  console.log($('tr.selected td').eq(1).html())
	} );
	
	
  });
//加载列表数据
function getTableData(){
	deleteAllRow(dataListId);
	//搜索框去除空格
	$("#wl_proName").val($("#wl_proName").val().trim());
	$("#wl_userOwner").val($("#wl_userOwner").val().trim());
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
		   dataType:'json',
		   success: function(myData){
		   if(isShowLog)console.log(myData);
			var data = baidu.template(dataListId+"-template",eval(myData));  
			$("#"+dataListId+"-body").html(data);
			  var option= {
					   ele:$("#"+dataListId+"-page")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:common_list_url+"?"+$("#"+searchFormId).serialize()
				   }
				generatePages(option);
		   }
		});	
  }

//设置模态框隐藏事件 
$( '#my_modal_add' ).on( 'show.bs.modal' ,function(e){  
	setToken();
}); 
//清空数据
function cleanData(id){
	$('#'+id).find(".clean").val("");//按照样式清空；
}
//打开添加页面
function toAdd(){
	cleanData('addForm_submitFormData');//清空模态窗口内数据
	$("#w_"+tableId).val("");
	$(".datepicker").val("");
	$('#my_modal_add').modal('show');
}

//获取对象值
function loadObj(type,paramData){
	$.ajax({
	    type:'get',
	   	url:common_info_url+"?doCode=dymicSql",
	    data: paramData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	showData(type,myData);
	  	}
	});	
}

//删除信息（逻辑删除）
function doDele(paramData){
	$.ajax({
	    type:"post",
	    url:common_submit_url+"?doCode=dymicSql",
	    data: paramData,
	    dataType:"json",
	    success: function(myData){
	    	var result = myData.flag;
	    	if(result=="T"){
	    		layer.alert("删除操作成功");
	    		refresh();
	    	}
	  	}
	});	
}

/**
 * 新增表单数据提交
 * @param formId
 */
function add(formId){
	var index_submit = layer.confirm('您确定要提交信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		$.ajax({
		    type:"post",
		    url:common_submit_url,
		    data:$("#"+formId).serialize(),
		    dataType:"json",
		    success: function(myData){
		    	//console.log(myData);
		    	if(myData.flag=="T"){
		    		layer.alert("数据保存成功");
		    		$("#my_modal_add").modal("hide");
		    	}else{
		    		layer.alert(myData.msg);
		    	}
		    	refresh();
		  	}
		});	
	});
}

/**
 * 修改表单数据提交
 * @param formId
 */
function edit(formId){
	var index_submit = layer.confirm('您确定要提交信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		$.ajax({
		    type:"post",
		    url:common_submit_url,
		    data:$("#"+formId).serialize(),
		    dataType:"json",
		    success: function(myData){
		    	//console.log(myData);
		    	if(myData.flag=="T"){
		    		layer.alert("数据保存成功");
		    		$("#my_modal_edit").modal("hide");
		    	}else{
		    		layer.alert(myData.msg);
		    	}
		    	refresh();
		  	}
		});	
	});
}

//关闭win
function cannel(type){
	if(strUtil.isNull(type)){
		$('#my_modal_add').modal('hide');
	}else{
		$('#my_modal_'+type).modal('hide');
	}
}

function refresh(){
	getTableData();
}


function setToken(){
	$.ajax({
	    type:'get',
	    url:'/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
	    	console.log(myData);
			$('#addForm_formToken').val(myData);
			$('#editForm_formToken').val(myData);
	  	}
	});	
}



/****  以下是自定义新增方法  ****/
 
</script>



